<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医院管理系统</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .welcome-container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            padding: 3rem;
            text-align: center;
            max-width: 500px;
            width: 100%;
        }
        .welcome-icon {
            font-size: 4rem;
            color: #667eea;
            margin-bottom: 1rem;
        }
        .welcome-title {
            color: #333;
            margin-bottom: 1rem;
        }
        .welcome-text {
            color: #666;
            margin-bottom: 2rem;
        }
        .btn-welcome {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            border-radius: 10px;
            padding: 12px 30px;
            font-weight: 600;
            color: white;
            text-decoration: none;
            display: inline-block;
            transition: transform 0.3s;
        }
        .btn-welcome:hover {
            transform: translateY(-2px);
            color: white;
        }
    </style>
</head>
<body>
    <div class="welcome-container">
        <div class="welcome-icon">
            <i class="fas fa-hospital"></i>
        </div>
        <h1 class="welcome-title">医院管理系统</h1>
        <p class="welcome-text">欢迎使用医院管理系统，请选择您的身份登录</p>
        <div class="d-grid gap-2">
            <a href="/login" class="btn btn-welcome">
                <i class="fas fa-sign-in-alt me-2"></i>立即登录
            </a>
            <a href="/register" class="btn btn-outline-primary">
                <i class="fas fa-user-plus me-2"></i>注册账户
            </a>
        </div>
    </div>

    <script src="/js/bootstrap.bundle.min.js"></script>
    <script>
        // 检查是否已登录
        const token = localStorage.getItem('token');
        const userInfo = localStorage.getItem('userInfo');
        
        if (token && userInfo) {
            const user = JSON.parse(userInfo);
            const userRole = user.uRole;
            
            // 根据角色跳转到对应首页
            if (userRole === 1) {
                window.location.href = '/admin/home';
            } else if (userRole === 2) {
                window.location.href = '/doctor/home';
            } else if (userRole === 3) {
                window.location.href = '/patient/home';
            }
        }
    </script>
</body>
</html>
